package com.huidao.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import com.huidao.entity.User;


public class ManaFilter implements Filter {

 
    public ManaFilter() {
 
    }


	public void destroy() {

	}


	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req=(HttpServletRequest) request;
		User user = (User) req.getSession().getAttribute("user");
		if(user==null){
			response.getWriter().print("请先登录");
		}else if(user.getRoleId().getRoleId()==3){
		chain.doFilter(request, response);
	}
	}

	public void init(FilterConfig fConfig) throws ServletException {
		// TODO Auto-generated method stub
	}

}
